package com.alveole.events.server;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.alveole.tools.Logger;


public class ServerEvent {

	protected final static String NULL = "";
	protected final static String SET=quote("set");

	private final Map<String,String> params = new HashMap<String,String>();
	
	public ServerEvent(String command)
	{
		addParam("command",command);
	}
	public void addParam(String key,String param)
	{
		params.put(key,quote(param));
	}
	public String getJSON()
	{
		String json="";
		json+="{";
		for (String key : params.keySet())
		{
			json+=getJSONEntry(key,params.get(key)) +",";
		}
		json=json.substring(0,json.length()-1);
		json+="}";
		
		return json;
	}
	protected String getJSONEntry(String param, String value)
	{
		return getJSONParam(param) + getJSONValue(value);
	}
	protected String getJSONParam(String param)
	{
		return quote(param)+":";
		
	}
	protected String getJSONValue(String value)
	{
		return value;
		
	}


	public static String quote(String value)
	{
		return "\""+value+"\"";
	}

}
